/*
 * @Description: 
 * @Author: yeeChen
 * @Date: 2022-12-16 16:30:31
 * @LastEditTime: 2022-12-16 16:36:30
 * @LastEditors: yeeChen
 */
// 1.创建http模块
const http = require('http')

// 2.创建服务器
const serve = http.createServer()

// 3.给服务器添加request事件
serve.on('request', function (req, res) {
    const str = `您请求的URL地址是${req.url},您请求的方式是${req.method}`
    //防止中文乱码的问题,调用res.setHeader()方法
    res.setHeader('Content-Type','text/html;charset=utf-8')
    res.end(str)
})

// 4.启动服务器
serve.listen(8080, function () {
    console.log('serve running at http://127.0.0.01:8080');
})